<%@ page language="java"  pageEncoding="UTF-8"%>
<%@ page import="crm.model.Material "%>
<%@ page import="crm.control.MaterialControl"%>
<%@ page import = "crm.control.DateControl"%>
<%@ page import ="crm.model.Salearea"%>
<%@ page import="crm.util.ParamUtil" %>
<%@ page import="java.util.*"  %>
<%@page import="crm.control.SaleareaControl"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>修改公告通知</title>
     <script language="javascript"> 
		function check()
		{
			    if(document.form1.material_name.value=="")
				{
					alert("资源名称不能为空");
					document.form1.material_name.focus();
					return;
				}
				else if(document.form1.upload_time.value=="")
				{
					alert("资源时间不能为空");
					document.form1.upload_time.focus();
					return;
				}
				else if(document.form1.sale_area_id.value=="")
				{
					alert("区域编号不能为空");
					document.form1.sale_area_id.focus();
					return;
				}else
				{form1.submit();}
		} 
  </script>
  </head>
  
<body>
   <%
      request.setCharacterEncoding("UTF-8");
      int id=ParamUtil.getInt(request,"id",0);
      Material material = new Material();
      MaterialControl mc = new MaterialControl();
	  material = mc.getMaterialInformation(id);
	  DateControl dc = new DateControl(); 
	  String time = dc.Date();  
	  ArrayList saleareas=SaleareaControl.getAllSaleareas();
	  String area="";
						for(int i=0;i<saleareas.size();i++)
						{
						  Salearea sa=(Salearea)saleareas.get(i);
						 
						   if(sa.getId()==material.getSale_area_id())
						     area+="<option value='"+sa.getId()+"' label='"+sa.getArea_name()+"' selected>"+sa.getArea_name()+"</option>";
						   else
						      area+="<option value='"+sa.getId()+"' label='"+sa.getArea_name()+"'>"+sa.getArea_name()+"</option>";
						}
%>
   <form name="form1" action="material_updatedo.jsp?id=<%=id%>" method="post" >
   <table>
        <tr>
            <td>资料标题：</td>
        </tr>
       <tr>
          <td>
             <input type="text" id="material_name" name="material_name" value="<%=material.getMaterial_name()%>" /><br>
          </td>
         </tr>
       
       
        <tr>
        <td>区域：</td>
        </tr>
       <tr>
        <td><select name="sale_area_id" id="sale_area_id" >
                         <%=area%>
                          </select><br/>
        </td>
        </tr>    
        <tr>
        <td>文件路径：</td>
        </tr>
       <tr>
        <td><input type="text" id="path"  name="path" value=<%=material.getPath()%> /><br/>
        </td>
        </tr>    
   <tr>
   <td>
	<input type="submit" id="submit" value="提交"  onClick="check()"/></td><td>
	<input type="reset" value="取消" onClick="window.location.href='material.jsp'"/>
	</td> 
	</tr>
</table>
</form>
  </body>
</html>
